package com.trainfinder;

import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.http.HttpServlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.trainfinder.ripper.sweep.SweepScheduler;

public class TimerSetup extends HttpServlet {

	private static final long serialVersionUID = 1L;

	private final static Timer TIMER = new Timer("Store", false);

	private final static SweepScheduler SCHEDUALER = new SweepScheduler();

	private final static Log LOG;

	static {
		Log log = null;
		try {
			log = LogFactory.getLog(TimerSetup.class);
		} catch (Exception e) {
	//		e.printStackTrace();
		}
		LOG = log;

		TimerTask timeTask = new TimerTask() {

			@Override
			public void run() {

				if (LOG != null) {
					LOG.info("checking schedualer");
					
				}
				SCHEDUALER.schedule();
			}
		};

		// final int day = 24 * 60 * 60 * 1000;
		// final int sevenHours = 7 * 60 * 60 * 1000;
		final int oneMin = 60 * 1000;
		final int oneHour =  60 * 60 * 1000;

		TIMER.schedule(timeTask, oneMin, oneHour);
	}

}
